package br.com.sitran.action;

import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpSession;

public class GeralAction {
	
	//redirecionamentos
	public String login(){
		return "login";
	}
	public String logout(){
		return "logout";
	}
	public String toHome(){
		return "toHome";
	}
	
	//mensagens
	public static void msgNavegacao(String msg, String nav) {   
	    FacesMessage facesMessage = new FacesMessage(msg);   
	    FacesContext.getCurrentInstance().addMessage(null, facesMessage);
	   
	    HttpSession sessao = (HttpSession) FacesContext.getCurrentInstance() 
		.getExternalContext().getSession(false);
		sessao.setAttribute("nav",nav);
	}
	
	public static String getNavegacao(){
		HttpSession sessao = (HttpSession) FacesContext.getCurrentInstance() 
		.getExternalContext().getSession(false);
		return sessao.getAttribute("nav").toString();
	}
	
	public String retornar(){
		return getNavegacao();
	}
	
}
